package com.sunyard.client2.ui;

import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;

import com.sunyard.client.SunEcmClientApi;
import com.sunyard.client2.ConnectionFactory;
import com.sunyard.client2.conf.ConfUtil;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class Permission extends JPanel {
	private JTextField textField;
	private JTextField textField_1;

	/**
	 * Create the panel.
	 */
	public Permission() {
		setLayout(null);

		JLabel lblNewLabel = new JLabel("用户：");
		lblNewLabel.setBounds(44, 68, 54, 15);
		add(lblNewLabel);

		textField = new JTextField();
		textField.setBounds(149, 65, 174, 21);
		textField.setText(ConfUtil.getString("userName", "admin"));
		add(textField);
		textField.setColumns(10);

		JButton btnNewButton = new JButton("查询");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				try {
					SunEcmClientApi clientApi = ConnectionFactory.getConnection();
					String resultMsg = clientApi.getPermissions_Client(textField.getText(), textField_1.getText());
					ResultMessageBox.getInstance().showMessage(resultMsg);
				} catch (Exception e1) {
					ResultMessageBox.getInstance().showMessage(e1.getMessage());
				}

			}
		});
		btnNewButton.setBounds(94, 147, 93, 23);
		add(btnNewButton);

		JLabel label = new JLabel("密码：");
		label.setBounds(44, 100, 54, 15);
		add(label);

		textField_1 = new JTextField();
		textField_1.setText(ConfUtil.getString("passWord", "111"));
		textField_1.setColumns(10);
		textField_1.setBounds(149, 97, 174, 21);
		add(textField_1);

	}

}
